import {baseUrl} from './config.js'
import {handlerErrorResponse,handlerErrorRequest} from './errorHandlers.js'

function request(config){
	console.log(config,'config__________');
	config.url = baseUrl+config.url
	// const token = localStorage.getItem('token')
	const token = uni.getStorage({
		key:'toekn'
	})
	if(token && token !== 'undefined'){
		config.header = {
			token:token
		}
	}
	
	return new Promise((reslove,reject)=>{
		uni.request(config).then(res=>{
			console.log(res,'res______');
			resolve(res)
		}).catch(err=>{
			console.log(err,'err___________');
			reject(err)
		})
	})
}

export default {request}